package com.example.qjia.Presenters;

import android.view.View;

import com.example.qjia.Listener.LoadMessagesListener;
import com.example.qjia.data.HolidayMessage;
import com.example.qjia.data.romotedata.AbsenceSlip;
import com.example.qjia.model.LoadMessageModel;
import com.example.qjia.model.LoadMessageModelImp;
import com.example.qjia.ui.ViewInterface.MainViewInterface;

import java.util.List;
import java.util.Map;

/**
 * Created by ying_xiang on 2016/8/12.
 */
public class LoadMessagePresenterImp implements LoadMessagePresenter,LoadMessagesListener {

    private LoadMessageModel loadMessageModel;
    private MainViewInterface mainViewInterface;

    public LoadMessagePresenterImp(MainViewInterface mainViewInterface) {
        this.mainViewInterface = mainViewInterface;
        loadMessageModel=new LoadMessageModelImp();
    }

    @Override
    public void onSeccess(List<AbsenceSlip> holidayMessages) {
        if(mainViewInterface!=null)

            mainViewInterface.loadMessage(holidayMessages);//给adapter 的data赋值

    }

    @Override
    public void onSeccessloadmore(List<AbsenceSlip> holidayMessage) {
        if(mainViewInterface!=null){
            mainViewInterface.loadMessage(holidayMessage );
        }
    }

    @Override
    public void toUserSetting(int fragmentId) {
        mainViewInterface.toUserSettingActivity(fragmentId);
    }

    @Override
    public void showSettingDialog(View view) {
        mainViewInterface.showSettingDialog(view);
    }

    @Override
    public void failed() {
        mainViewInterface.loadnothing();
    }

    @Override
    public void toAddholiday() {
        mainViewInterface.toAddActivity();
    }

    @Override
    public void loadMessage() {
        loadMessageModel.loadMessages(this);

    }

    @Override
    public void loadmoreMessage(Map<String,String> params) {
        loadMessageModel.loadMoreMessage(params,this);

    }

    @Override
    public void destroy() {
        loadMessageModel=null;
        mainViewInterface=null;


    }
}
